package com.car.sale.service;

import com.car.sale.mapper.CarProductMapper;
import com.car.sale.mapper.CarSaleMapper;
import com.car.sale.vo.Car;
import com.car.sale.vo.Count;
import com.car.sale.vo.Month;
import com.car.sale.vo.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class FuelService {
    @Autowired
    private CarProductMapper carProductMapper;
    @Autowired
    private CarSaleMapper carSaleMapper;
    List<String> carSize;
    public List<Count> getFuelCount() {
        return carSaleMapper.getCountByFuel();
    }

    public List<Month> getFuelMonth() {
        carSize = carProductMapper.getCarFuel();
        List<Month> monthList = new ArrayList<>();
        for (int i = 0; i < carSize.size(); i++)
        {
            Month month = new Month();
            month.setType(carSize.get(i));
            month.setMonth(carSaleMapper.getMonthByFuel(month.getType()));
            monthList.add(month);
        }
        return monthList;
    }


}
